authors: Luis Tobalina, Thomas Cokelaer Nov 2014

see also the Boolean analysis example.ipynb notebook to generate the solution using CellNOptR genetic algorithm .

How to use the MILP model to train a boolean signaling network from experimental data using the milp module.


In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [9]:
import pulp
from cno import cnodata, CNOGraph, XMIDAS

In [10]:
import cno.milp.model

In [82]:
# select a prior knowledge network (pkn) and a dataset in midas format
filename_pkn = cnodata("PKN-ToyMMB.sif")
filename_midas = cnodata("MD-ToyMMB.csv")

#filename_pkn = cnodata("PKN-LiverDREAM.sif")
#filename_midas = cnodata("MD-LiverDREAM.csv")

In [83]:
# load pkn and midas
pkn = CNOGraph(filename_pkn, filename_midas)
midas = pkn.midas

In [84]:
# we can compress the network to reduce the problem size
pkn.compress()

In [85]:
pkn.expand_and_gates()

In [86]:
# instantiate a MILPTrain object from a given pkn and midas data and solve the optimization problem
milp_model = cno.milp.model.MILPTrain(pkn, midas)
milp_model.train()
print('Error:', pulp.value(milp_model.error_objective_expression()))
print('Size:', pulp.value(milp_model.size_objective_expression()))


('Error:', 10.01999999999998)
('Size:', 9.0)

In [87]:
# we can retrieve a dictionary with the reactions as keys and a 1 or a 0 as value 
# indicating if the reaction is present in the optimized network or not
rxn_sol = milp_model.get_rxn_solution()

In [88]:
pkn2 = CNOGraph()

In [89]:
for i in rxn_sol:
    if rxn_sol[i]==1:
        pkn2.add_reaction(i)

In [90]:
pkn2.add_nodes_from(pkn.species)
pkn2.midas = midas
pkn2.png


Out[90]:

In [91]:
# solution from GA cellnopt
bs = [1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0]
reactions = ['EGF=PI3K', 'TNFa=PI3K', 'Jnk=cJun', 'PI3K=Akt', 'Raf=Mek',
        '!Akt=Mek', 'Mek=p90RSK', 'Mek=Erk', 'Erk=Hsp27', 'TNFa=Jnk',
        'TNFa=NFkB', 'TNFa=Hsp27', 'EGF=Raf', 'EGF+TNFa=PI3K',
        'Raf+!Akt=Mek', 'Erk+TNFa=Hsp27']

In [92]:
pkn3 = CNOGraph()
for b, r in zip(bs, reactions):
    if b==1: pkn3.add_reaction(r.replace("+","^"))
pkn3.add_nodes_from(pkn.species)
pkn3.midas = midas

In [93]:
pkn2 == pkn3


Out[93]:
True

In [94]:
pkn3.png


Out[94]:

In [95]:
pkn2.png


Out[95]:

In [ ]: